import { _decorator, Component, Node, Vec2, Vec3 } from 'cc';
const { ccclass, property } = _decorator;

@ccclass('Fire')
export class Fire extends Component {

    private direction: Vec2;
    private speed = 100;
    
    init(position: Vec3, direction: Vec2) {
        this.node.setPosition(position);
        this.direction = direction;
    }

    start() {

    }

    update(deltaTime: number) {
        // const distance =  this.direction.multiply3f(this.speed * deltaTime,this.speed * deltaTime,0);
      
       const distX = this.speed * deltaTime * this.direction.x;
       const distY = this.speed * deltaTime * this.direction.y;
       const newX = this.node.position.x + distX;
       const newY = this.node.position.y + distY;
        // this.node.position = this.node.position.add(distance);
        this.node.setPosition(newX, newY);
        // console.log(`newX:${newX}+,newY:${newY},dir:${this.direction}`)
    }
}


